package com.zzt.community.util;

import com.zzt.community.entity.User;
import org.springframework.stereotype.Component;

/**
 * Classname: HostHolder
 * Package: com.zzt.community.util
 * Description:持有用户信息，用于代替session对象
 *
 * @Author:zzt
 * @Create: 2024/3/10-23:59
 * Version:
 */
@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }

    public void clear() {
        users.remove();
    }
}
